package pierwszy;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.openqa.selenium.By;

public class UiMapping {
	//logIn(String login, String password)
	public static By LoginField = By.xpath("//input[@name='fusername']");
    protected static By PasswordField = By.xpath("//input[@name='fpassword1']");
    public static By LoginButton = By.xpath("//input[@name='btn_login']");
    
    //checkIfLogged(String sites)
    public static By LogOutButton = By.xpath("//img[@alt='Wyloguj']");
    public static By LogOutButtonKsPortalPage = By.xpath("//a/img[@id='ikonkalogwanie']");
    
    //chooseSite(String site)
    public static By ChooseBtn = By.xpath("//div/input[@value='Wybieram']");
    public static By SelectedSite = By.xpath("//dl[@id='wlog']/dd[1]/div[1]/form/select/option[@selected]");
    
    //getOptionFromIconPlus(String optionIconPlus)
    public static By IconPlus = By.xpath("//div/img[@id='ikonkaplus']");
    public static By IconPlusCheck = By.xpath("//div[@class='menu_mod']/div[@class='tl']");
    
    
    //addNote()
    public static By NoteCategoryList = By.xpath("//div[@class='selectric']/b[@class='button']");
    
    public static By passNoteCategory (String noteCategory){
    	return By.xpath("//select[@name='status']/option[text()='" + noteCategory + "']");
    }
    
    public static By passNoteFilterCategory (String noteCategory){
    	return By.xpath("//div[@class='selectricItems']/ul/li[text()='" + noteCategory + "']");
    }
    
    public static By NoteTextArea = By.xpath("//div[@class='wartoscPola']/textarea");
    public static By NoteSaveButton = By.xpath("//div[@class='przyciskiPola']/input[@class='blackp']");
    //public static By NoteTextAreaCheck = By.xpath("//tr[@class='wiersz_tab']/td/a[text()='Notka1 WP. ']");
    //public static By NoteRemoveButton = By.xpath("//tr[@class='wiersz_tab']/td/a[text()='Notka1 WP. ']/../following-sibling::td/a[@onclick]");
    
    public static By notesContent = By.xpath("//tbody/tr/td");
    
    public static By passNoteContentCheck (String noteContent){
    	return By.xpath("//tr[@class='wiersz_tab']/td/a[text()='" + noteContent + " ']");
    }
    
    public static By passNoteContentButton (String noteContent){
    	return By.xpath("//tr[@class='wiersz_tab']/td/a[text()='" + noteContent + " ']/../following-sibling::td/a[@onclick]");
    }
    
    public static By passSite(String sites){
    	return By.xpath("//div/span[text()='" + sites + "']/preceding-sibling::input[@type='radio']");
    }
    
    public static By passOptionOfIconPlus(String optionIconPlus){
    	return By.xpath("//span[@class='strzalka_n']/following-sibling::a[text()='" + optionIconPlus + "']");
    }
    
    
    //addAktualnosc()
    public static By NewsTitle = By.xpath("//div[@class='wartoscPola']/input[@class='ramkaPola'][@name='ftitle[pl]']");
    public static By NewsShortage = By.xpath("//div[@class='wartoscPola']/textarea[@class='ramkaPola'][@name='fskrot[pl]']"); 
    public static By NewsTextArea = By.xpath("//tbody/tr/td/iframe[@id='idContentofcontentpl']");
    public static By NewsTextAreaIFrame = By.xpath("//html/body");
    
    public static By NewsCount = By.xpath("//div[@class='szare_tlo']/div[@class='ilosc']/span");
    public static By NewsDateTime = By.xpath("//div[@class='wartoscPola']/input[@class='ramkaPola'][@value!='']");
    public static By NewsDateTimeCheck = By.xpath("//dd[@class='pa_bgw_sp']/strong[text()='Data i czas utworzenia:']/..");
    public static By NewsReturnBtn = By.xpath("//a[@class='box_przycisk'][text()='Powrót']");
 
    public static By NewsSubmitButton = By.xpath("//div[@class='przyciskiPola']/input[@value='Dodaj aktualność']");
    public static By NewsTextTab = By.xpath("//td[@id='dane']/a[text()='Treść']");
    public static By NewsTextAreaCheck = By.xpath("//div[@id='show_dane']");
    public static By NewsRemoveButton = By.xpath("//div[@class='box_info_2']/a[text()=('[-] Usuń')]");
    
    public static By passNewsTitle(String title, String date){
    	return By.xpath("//tr[@class='wiersz_tab']/td[text()='" + date + "']/preceding-sibling::td/a[text()='" + title + "']");
    }
    
    //Employee
    public static By nameOfUser =     By.xpath("//div[@class='opisPola'][text()='Nazwa użytkownika:']/following-sibling::div/input[@name='flogin']");
    public static By firstPassword =  By.xpath("//div[@class='opisPola'][text()='Hasło:']/following-sibling::div/input[@name='fpass_1']"); 
    public static By secondPassword = By.xpath("//div[@class='opisPola'][text()='Powtórz hasło:']/following-sibling::div/input[@name='fpass_2']");
    public static By firstName =      By.xpath("//div[@class='opisPola'][text()='Imię:']/following-sibling::div/input[@name='fname']");
    public static By lastName =       By.xpath("//div[@class='opisPola'][text()='Nazwisko:']/following-sibling::div/input[@name='flastname']");
    public static By userNumber =     By.xpath("//div[@class='opisPola'][text()='Numer pracownika:']/following-sibling::div/input[@name='numer']");
    public static By city =           By.xpath("//div[@class='opisPola'][text()='Miasto:']/following-sibling::div/input[@name='fcity']");
    public static By postalCode =     By.xpath("//div[@class='opisPola'][text()='Kod pocztowy:']/following-sibling::div/input[@name='fpost_code']");
    public static By address =        By.xpath("//div[@class='opisPola'][text()='Adres:']/following-sibling::div/textarea[@name='faddress']");
    public static By phoneNumber =    By.xpath("//div[@class='opisPola'][text()='Telefon:']/following-sibling::div/input[@name='fphone']");
    public static By emailAddress =   By.xpath("//div[@class='opisPola'][text()='E-mail:']/following-sibling::div/input[@name='femail']");
    public static By website =        By.xpath("//div[@class='opisPola'][text()='www:']/following-sibling::div/input[@name='fwww']");
    public static By additionalInfo = By.xpath("//div[@class='opisPola'][text()='Dodatkowe informacje:']/following-sibling::div/textarea[@name='fadditional_info']");
    
    //addEmplyee
    public static By addEmployeeBtn = By.xpath("//div[@class='przyciskiPola']/input[@name='btn_add_employee']");
    
    //cleanEmployeeInfo
    public static By cleanEmplyeeBtn = By.xpath("//div[@class='przyciskiPola']/input[@value='Wyczyść']");
    
    //findEmployee
    public static By passUserLoginAndName(String login, String firstName, String lastName){
    	return By.xpath("//td[contains(.,'" + firstName.concat(" ").concat(lastName) + "')]/preceding-sibling::td/a[contains(.,'" + login + "')]");
    }
    
    public static By passUserLoginNameAndOption(String login, String firstName, String lastName, String option){
    	return By.xpath("//td[contains(.,'" + firstName.concat(" ").concat(lastName) + "')]/preceding-sibling::td/a[contains(.,'" + login + "')]/../..//li[text()='" + option + "']");
    }
    
    public static By passOptionsOfEmployeeBtn(String login, String firstName, String lastName){
    	return By.xpath("//td[contains(.,'" + firstName.concat(" ").concat(lastName) + "')]/preceding-sibling::td/a[contains(.,'" + login + "')]/../..//div[@class='selectric']/b");
    }
    
    public static By passUserPosession(String posession){
    	return By.xpath("//div[@class='opisPola'][text()='Stanowisko:']/following-sibling::div/select[@name='fpost']/option[text()='" + posession + "']");
    }
   
    public static By passSelectedSite(String selectedSite){
    	return By.xpath("//dl[@id='wlog']/dd[1]/div[1]/form/select/option[contains(.,'" + selectedSite + "')]");
    }
    
    public static By employeeLocation = By.xpath("//div[@class='pdown']/a[contains(.,'Lokalizacja')]");
    
    public static By employeeLocationFieldNames = By.xpath("//div[@class='divPola']/div[@class='wartoscPola']/*/../../div[@class='opisPola']");
    
    public static By employeeLocationFieldValues = By.xpath("//div[@class='divPola']/div[@class='wartoscPola']/*");
    
    public static By locationMenuList = By.id("ikonkarozwin");
    
    public static By addLocationListOption = By.linkText("[+] Lokalizacje");
    
    public static By addLocationBtn = By.name("btn_add_lokalizacja");
    
    public static By locationIds = By.xpath("//div[contains(.,'Lokalizacje (lista lokalizacji)')]/following-sibling::div/dl/dd[1]/a[@href]");
    
    public static By passLastLocationId(int lastId){
    	return By.xpath("//div[contains(.,'Lokalizacje (lista lokalizacji)')]/following-sibling::div/dl/dd[1]/a[@href='http://www.ksiegowoscngo.pl/admin.php?m=lokalizacja&o=showLokalizacja&id=" + lastId + "']");
    }
    
    public static By locationOpis = By.id("show_opis");
    
    public static By locationOpisBtn = By.xpath("//*[@id='opis']/a");
    
    public static By locationContent = By.xpath("//dl[@class='pa_bwg']");
    
    public static List<By> listOfLocatorsForUser (String userProfession){
    	List<By> usersLocatorsList = new ArrayList<By>();
    	
    	usersLocatorsList.add(nameOfUser);
    	usersLocatorsList.add(firstPassword);
    	usersLocatorsList.add(secondPassword);
    	usersLocatorsList.add(firstName);
    	usersLocatorsList.add(lastName);
    	usersLocatorsList.add(userNumber);
    	usersLocatorsList.add(UiMapping.passUserPosession(userProfession));
    	usersLocatorsList.add(city);
    	usersLocatorsList.add(postalCode);
    	usersLocatorsList.add(address);
    	usersLocatorsList.add(phoneNumber);
    	usersLocatorsList.add(emailAddress);
    	usersLocatorsList.add(website);
    	usersLocatorsList.add(additionalInfo);
    	
    	return usersLocatorsList;
    }
    
    
    //Client
    
    //Client= Natural Person (Osoba fizyczna)
    public static By naturalPersonLogin = By.name("login");
    public static By naturalPersonFirstPasswd = By.name("fpass_1");
    public static By naturalPersonSecondPasswd = By.name("fpass_2");
    public static By naturalPersonFirstName = By.name("fname");
    public static By naturalPersonLastName = By.name("flastname");
    
    public static List<By> listOfLocatorsForClientNaturalPerson (){
    	List<By> naturalPersonLocatorsList = new ArrayList<By>();
    	
    	naturalPersonLocatorsList.add(naturalPersonLogin);
    	naturalPersonLocatorsList.add(naturalPersonFirstPasswd);
    	naturalPersonLocatorsList.add(naturalPersonSecondPasswd);
    	naturalPersonLocatorsList.add(naturalPersonFirstName);
    	naturalPersonLocatorsList.add(naturalPersonLastName);
    	
    	return naturalPersonLocatorsList;
    }
    
    //Client = Company (Firma)
    //public static By companyEmail = By.name("login");
    public static By companyFirstPasswd = By.id("fpass_1");
    public static By companySecondPasswd = By.id("fpass_2");
    public static By companyFullName = By.xpath("//div[contains(.,'Nazwa pełna')]/div/textarea[@name='nazwa']");
    public static By companyShortName = By.xpath("//div[contains(.,'Nazwa podmiotu')]/div/input[@name='skrocona']");
    
    public static List<By> listOfLocatorsForClientCompany (){
    	List<By> companyLocatorsList = new ArrayList<By>();
    	
    	//clientLocatorsList.add(companyEmail);
    	companyLocatorsList.add(companyFirstPasswd);
    	companyLocatorsList.add(companySecondPasswd);
    	companyLocatorsList.add(companyFullName);
    	companyLocatorsList.add(companyShortName);
    	
    	return companyLocatorsList;
    }
    

    public static By nextCompanyClientBtn = By.xpath("//div[@class='przyciskiPola']/input[@name='btn_dalej']");
    
  //div[@id='show_dane_main']/div[contains(.,'2 / 6')]
    public static By addClientCheckNextPage(String siteNumber){
    	return By.xpath("//div[@id='show_dane_main']/div[contains(.,'" + siteNumber + " / 6')]");
    }
    
    public static By checkSelectedClientType = By.xpath("//div[@class='tresc_box_1']/div/div[contains(@class,'naglowek')]");

    public static By passClientType(String clientType){
    	return By.xpath("//div[@id='bez_mat']/a[contains(.,'Dodaj klient - " + clientType + "')]");
    }
    
    public static By passClientEmailLogin(String clientEmailLogin){
    	return By.xpath("//div[text()='" + clientEmailLogin + ":']/following-sibling::div/input[@name='" + clientEmailLogin.toLowerCase() + "']");
    }
    
    public static By passClientEmailLoginAvailibility(String clientEmailLogin){
    	return By.xpath("//div/input[@value='" + clientEmailLogin + "']");
    }
    
    public static By loginAvailibilityBtn = By.xpath("//div/input[@name='btn_spr_login']");
    public static By emailAvailibilityBtn = By.xpath("//div/input[@name='btn_spr_regon']");
    
    public static By loginAvailibility = By.xpath("//div[@class='tresc_box_1']/div/div[contains(.,'Ten login jest juŻ zajĘty')]");
    public static By emailAvailibility = By.xpath("//div[@class='tresc_box_1']/div");
    
    public static By addCompanyBtn = By.xpath("//div/input[@name='btn_add_ogloszenia']");
    
    public static By addNaturalPersonBtn = By.xpath("//div/input[@name='btn_re'][@value='Dodaj']");
    
    public static By removeCompanyBtn = By.xpath("//div[@class='box_info_2']/span/a[contains(.,'Usuń abonenta')]");
    
    public static By passCompanyName(String companyName){
    	return By.xpath("//div/table/tbody/tr/td/a[text()='" + companyName + "']");
    }
   
    public static By passNaturalPersonNameAndLogin(String[] NaturalPersonData){
    	String Name = NaturalPersonData[3].concat(" ").concat(NaturalPersonData[4]);
    	String Login = NaturalPersonData[0];
    	
    	return By.xpath("//div/table/tbody/tr/td/a[contains(.,'" + Name + "')]/../following-sibling::td/a[contains(.,'" + Login +"')]/../following-sibling::td/a/img[@title='Usuń']");
    }
    
    public static By AmountOfElements = By.xpath("//div/div[contains(.,'Liczba pozycji:')]/span");
    
    public static By commissionTranlationTitle = By.cssSelector("input.ramkaPola[name='tytul']");
    
    public static By commissionTranlationDescription = By.id("idContentofcontentpl");
    public static By commissionTranlationDescriptionIFrame = By.xpath("html/body");
    public static By commissionTranlationCalendar = By.xpath("//img[contains(@alt,'Wybierz datę wygaśniecia wpisu')]/..");
    
    public static By passCommissionDate(String date){
    	return By.xpath("//td/font[contains(.,'Lipiec 2014')]/ancestor::tbody/tr//font[text()=10]");
    }
    public static By commissionTranlationMinutes = By.xpath("//select[@id='godzina']/following-sibling::input"); 
    
    public static By comissionTranslationDefineCustomer = By.xpath("//div[@class='blackp'][contains(.,'Wybierz firmę/klienta')]"); 
    public static By comissionTranslationSetCustomer = By.xpath("  //*[@id='pudelkoKlientAjax']/div/div[@onclick='zatwierdzKlient();']"); 
    public static By passComissionTranslationCustomerName(String customerName){
    	return By.xpath("//label[contains(@id,'nameKlient')][text()='" + customerName + "']/preceding-sibling::input");
    }
    
    public static By comissionTranslationDefineAccountant = By.xpath("//div/input[@onclick='pokaz_pracownicy();']"); 
    public static By comissionTranslationSetAccountant = By.xpath(".//*[@id='myDivElement_pracownicy']//input[@value='Zapisz i zamknij']"); 
    public static By passComissionTranslationAccountantName(String accountantName){
    	return By.xpath("//*[@id='myDivElement_pracownicy']//tbody/tr/td[text()='" + accountantName + "']/input");
    }
  
    public static By comissionTranslationSetDate = By.xpath("//div[@class='wartoscPola']/input[@name='date']"); 
    
    public static By comissionTranslationSubmit = By.xpath("//input[@name='btn_add_zlecenia']"); 
    
    public static By comissionTranslationFindSites = By.xpath("//tr/td/span[@class='tutaj'] | //tr/td/a/span[@class='czcionka_szary_11']/.. ");
    
    public static By comissionTranslationFind = By.cssSelector("tr.wiersz_tab>td.tab15");
    
    public static By passComissionTranslationAccountantName(int id, String date, String title){
    	return By.xpath("//tr[@class='wiersz_tab']/td[@class='tab15']/following-sibling::td[text()='" + date + "']/preceding-sibling::td/a[text()='" + title + "'][contains(@href,'id=" + id + "')]");
    }
    
    public static By removeTranslationBtn = By.xpath("//a[contains(.,'Usuń zlecenie')]");
    
    public static By commissionDataCheck = By.xpath("//dl[@class='pa_bwg']/dd[text()]");
    
    
    public static By zlecenieUSAbonentPrzycisk = By.id("bFirma");
    public static By zlecenieUSWybierzKlienta = By.xpath("//div[@class='blackp'][contains(.,'Wybierz klienta')]");
    public static By zlecenieUSZlecenia = By.xpath(".//*[@id='pudelkoZleceniaAjax']/div[contains(.,'Czynność niepowiązana')]/input");
    
    public static By passZlecenieUSZlecenia(String typZlecenia){
    	return By.xpath(".//*[@id='pudelkoZleceniaAjax']/div[contains(.,'" + typZlecenia + "')]/input");
    }
      
    public static By zlecenieUSPolaInput = By.xpath("//div[@class='wartoscPola']/input");
    
    public static By zleceniaUSUwagi = By.cssSelector("textarea[name=uwagi]");
    
    public static By zleceniaUSDodaj = By.name("btn_add_podatek");
    
    public static By zlecenieUSPolaDoSprawdzenia = By.xpath("//div[@class='divPola']");
    
    public static By listaZlecenUS = By.linkText("Podatki");
    
    public static By stronyZlecenieUS = By.xpath("//td[text()='Strony']/following-sibling::td/a/span[@class='czcionka_szary_11'] | //td[text()='Strony']/following-sibling::td/strong");
    
    public static By zleceniaUSNaStronie = By.xpath("//tr/td[2]/a[contains(@href,'&id=')]");
    public static By wszystkieZleceniaUSNaStronie = By.xpath("//tr/td[3]/a[contains(@href,'&id=')]");
       
    public static By passIdUSZlecenia(int idZleceniaUS){
    	return By.xpath("//td[@class='zestawienia_podstawowa0']/a[text()=" + idZleceniaUS + "]/../..");
    }
    
    public static By passIDUsunZLecenieUS(int idZleceniaUS){
    	return By.xpath("//td/a[contains(@href,'&id=" + idZleceniaUS + "')]/img[@title='Usuń']");
    }
    
    public static By iloscZlecenUS = By.xpath("//div[@class='box_przycisk2N']/span");
    
    public static By skladkaZusWybierzKlientaBtn = By.xpath("//div[@class='blackp'][contains(.,'Wybierz firmę/klienta')] ");
    public static By skladkaZusWybierzKlienta = By.xpath("  //*[@id='pudelkoKlientAjax']/div/div[@onclick='zatwierdzKlient();']"); 
    
    public static By passSkladkaZusNazwaKlienta(String nazwaKlienta){
    	return By.xpath("//label[contains(@id,'nameKlient')][text()='" + nazwaKlienta + "']/preceding-sibling::input");
    }
    
    public static By skladkaZusPolaInput = By.xpath("//div[@class='wartoscPola']/input[@type='text']");
    
    public static By passSkladkaZusTypZlecenia(String typZlecenia){
    	return By.xpath(".//*[@id='pudelkoZleceniaAjax']/div[contains(.,'" + typZlecenia + "')]/input");
    }
    
    public static By skladkaZusUwagi = By.cssSelector("textarea[name=uwagi]");
    
    public static By skladkaZusDodaj = By.xpath("//*[@id='add']//input[@name='btn_add_zus']");
    public static By skladkaZusDodaj2 = By.xpath("//*[@id='potwierdzanie']//input[@name='btn_add_zus']");
    
    public static By zmodyfikowanaSkladkaZusDodaj = By.xpath("//*[@id='add']//input[@name='btn_mod_zus']");
    public static By zmodyfikowanaSladkaZusDodaj2 = By.xpath("//*[@id='potwierdzanie']//input[@name='btn_mod_zus']");
    
    public static By skladkaZusKomunikat = By.id("komunikat");
    
    public static By skladkaZusPolaDoSprawdzenia = By.cssSelector("div.divPola");
    
    public static By listaSkladekZusBtn = By.linkText("Zus-y");
    
    public static By stronySkladkiZus = By.xpath("//td[text()='Strony']/following-sibling::td/a/span[@class='czcionka_szary_11'] | //td[text()='Strony']/following-sibling::td/strong");
    
    public static By wszystkieFirmy = By.xpath("//*[@id='pudelkoKlientAjax']/div/div/input[@name='id_klient_ajax']/..");
    
    public static By passFirmaNipSkladkaZus(String nip, String firma){
    	return By.xpath("//*[@id='pudelkoKlientAjax']/div/div/label[text()='" + nip + "']/span[text()='" + firma + "']/../../input");
    }
    
    public static By passFirmaNipSkladkaZus(String firma){
    	return By.xpath("//*[@id='pudelkoKlientAjax']/div/div/label/span[text()='" + firma + "']/../../input");
    }
    
    public static By nazwaNipFirmy = By.id("pudelkoKlient");
    
    public static By modyfikujSkladkeZusBtn = By.linkText("[m] modyfikuj");
    
    public static By wyczyscPolaSklaskiZusBtn = By.xpath("//*[@id='add']//input[@value='Wyczyść']");
    
    public static By opcje = By.cssSelector("#dt_options");
    
    public static By przekazOpcje(String opcja){
    	return By.linkText(opcja);
    }
    
    public static By polaInputUrzedu = By.cssSelector(".wartoscPola>input");
    
    public static By polaUrzeduDoSprawdzenia = By.xpath("//div[@class='divPola']");
    
    public static By dodajUrzadBtn = By.name("btn_add");
 
    public static By przekazNazweUrzedu(Map<String, String> daneUrzedu){
    	return By.xpath("//td/a[@class='gallery_tab'][contains(.,'" + daneUrzedu.get("Nazwa") + "')]/../following-sibling::td[contains(.,'" + daneUrzedu.get("Miasto") + "')]/following-sibling::td[contains(.,'" + daneUrzedu.get("Telefon") + "')]/following-sibling::td[contains(.,'" + daneUrzedu.get("Fax") + "')]/a");
    }
    
    public static By powrotBtn = By.xpath("//div/a[@class='box_przycisk']/span/..");
    
    public static By usunBtn = By.linkText("[-] usuń");
    
    public static By polaNowegoPodatku = By.cssSelector(".ramkaPola");
    public static By dodajNowyPodatekBtn = By.cssSelector(".blackp[value=Dodaj]");
    public static By wyczyscNowyPodatekBtn = By.cssSelector(".blackp[value=Wyczyść]");
    
    public static By podatkiNaStronie = By.xpath("//tr/td[2]/a[contains(@href,'&id=')]/../preceding-sibling::td");
    
    public static By passIdPodatku(int idPodatku){
    	return By.xpath("//td[@class='zestawienia_podstawowa0'][text()='" + idPodatku + "  ']/..");
    }
    
    public static By passIdNowegoPodatku(int idPodatku){
    	return By.xpath("//td[@class='zestawienia_podstawowa0'][text()='" + idPodatku + "  ']/following-sibling::td/a[@class='gallery_tab']");
    }
    
    public static By polaNowegoPodatkuSprawdz = By.cssSelector(".wartoscPola");
}


